<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Daftar_akun_pengguna extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }
	
	function insert($akun_pengguna)
	{
		$this->db->insert('akun_pengguna',$akun_pengguna);
	}
	
	function check_username($username)
	{
		$query = $this->db->get_where('akun_pengguna', array('username' => $username),1,0);
		
		if($query->num_rows() > 0)
		{
			return FALSE;
		}
		else
		{
			return TRUE;
		}
	}
	
	function check_email($email)
	{
		$query = $this->db->get_where('akun_pengguna', array('alamat_email' => $email),1,0);
		
		if($query->num_rows() > 0)
		{
			return FALSE;
		}
		else
		{
			return TRUE;
		}
	}
	
	function check_login_member($username, $password)
	{
		$query = $this->db->get_where('akun_pengguna', array('username' => $username, 'password' => $password, 'status'=>'aktif'), 1, 0);
		if ($query->num_rows() > 0)
		{
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}
	
	function data_login_member($username)
	{
		$this->db->select('*');		
		$this->db->from('akun_pengguna');
		$this->db->where('username', $username);		
		$query = $this->db->get();		
		return $query->row();
	}
}